<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<!-- 
	Copyright (C) 2007, 2008, 2009, 2010, 2011. PARP Research Group.
	<http://perception.inf.um.es>
	University of Murcia, Spain.

	This file is part of the QVision library.

	QVision is free software: you can redistribute it and/or modify
	it under the terms of the GNU Lesser General Public License as
	published by the Free Software Foundation, version 3 of the License.

	QVision is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public
	License along with QVision. If not, see <http://www.gnu.org/licenses/>.
-->

<html><head><meta http-equiv="content-Type" content="text/html;charset=UTF-8">
<title>QVision: Qt&#39;s Image, Video and Computer Vision Library</title>
<meta name="title" content="QVision" />
<meta name="dc.title" content="QVision" />
<meta name="url" content="http://perception.inf.um.es/QVision" />
<meta name="author" content="PARP Research Group - http://perception.inf.um.es" />
<meta name="revisit-after" content="30 DAYS"/>
<meta name="robots" content="index,follow"/>
<meta name="classification" content="*">
<meta name="rating" content="Safe For Kids">
<meta name="distribution" content="GLOBAL"/>
<meta name="description" content="Qt's Image, Video and Computer Vision Library"/>
<meta name="page-topic" content="Computer Vision research and prototype programming"/>
<meta name="geo.country" content="ES" />

<!--
Keywords:
By license:		open source, gnu, lgpl, gpl, free
By theme:		computer vision, image processing, robotics, programming, source, development
By usage:		library, toolkit, framework, prototype, application
By programming specs:	object oriented, c++, block programming, reusability, gui, graphical, parallel computing, high performance, GPU, prototyping
Interoperability with:	Qt, GSL, GNU Scientific library, OpenCV, CGAL, QWT, CUDA, mplayer, IPP, Intel Image Performance Primitives, blas, lapack
Functionallity:		image features, matrix algebra, projective geometry, mser, function minimization, function optimization, canny operator, harris operator, corner detection, performance evaluation, cpu usage, graphical interface
Main data-types:	matrix, vector, tensor, quaternion, image, polyline
Video sources:		webcam, camera, stream
Devices:		embedded, desktop computer, laptop, mini-laptop
Authors:		PARP research group. University of Murcia, Spain.
-->

<meta name="keywords" content="augmented reality, sfm, structure from motion, open source, gnu, lgpl, gpl, free, computer vision, image processing, robotics, programming, source, development, library, toolkit, framework, prototype, application, object oriented, c++, block programming, reusability, gui, graphical, parallel computing, high performance, GPU, prototyping, Qt, GSL, GNU Scientific library, OpenCV, CGAL, QWT, CUDA, mplayer, IPP, Intel Image Performance Primitives, blas, lapack, image features, matrix algebra, projective geometry, mser, function minimization, function optimization, canny operator, harris operator, corner detection, performance evaluation, cpu usage, graphical interface, matrix, vector, tensor, quaternion, image, polyline, webcam, camera, stream, embedded, desktop computer, laptop, mini-laptop, University of Murcia, Spain, PARP research group, vision por computador"/>
<meta http-equiv="keywords" content="augmented reality, sfm, structure from motion, open source, gnu, lgpl, gpl, free, computer vision, image processing, robotics, programming, source, development, library, toolkit, framework, prototype, application, object oriented, c++, block programming, reusability, gui, graphical, parallel computing, high performance, GPU, prototyping, Qt, GSL, GNU Scientific library, OpenCV, CGAL, QWT, CUDA, mplayer, IPP, Intel Image Performance Primitives, blas, lapack, image features, matrix algebra, projective geometry, mser, function minimization, function optimization, canny operator, harris operator, corner detection, performance evaluation, cpu usage, graphical interface, matrix, vector, tensor, quaternion, image, polyline, webcam, camera, stream, embedded, desktop computer, laptop, mini-laptop, University of Murcia, Spain, PARP research group, vision por computador"/>
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="title" content="QVision"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="tabs.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="favicon.ico" />
</head><body>

<table width="100%"><tr>
	<td><a href="http://perception.inf.um.es/"><img src="parp.png" border="0" /> <big>PARP Research Group</big></a></td>
	<td align="right"><a href="http://www.um.es/"><big>Universidad de Murcia</big> <img src="um.png" border="0" /></a></td>
</tr></table>

<hr /><br />

<table width="95%" align="center"><tr><td>

<!-- Generated by Doxygen 1.6.3 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
          <form id="FSearchBox" action="search.php" method="get">
            <img id="MSearchSelect" src="search/search.png" alt=""/>
            <input type="text" id="MSearchField" name="query" value="Search" size="20" accesskey="S" 
                   onfocus="searchBox.OnSearchFieldFocus(true)" 
                   onblur="searchBox.OnSearchFieldFocus(false)"/>
          </form>
        </div>
      </li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="ManualSections.html">The manual</a>
  </div>
</div>
<div class="contents">


<h1><a class="anchor" id="HelloWorld">Hello world </a></h1><p>As any other <em>Qt</em>-based application, QVision applications are created from <em>Qt</em> projects. A <a href="http://doc.trolltech.com/4.3/qmake-project-files.html">Qt project file</a> specifies the source files and requirements necessary to create any Qt application. The following is the content of an example Qt project file. The project will contain a single C++ source file named <em>example.cpp</em>:</p>
<div class="fragment"><pre class="fragment">include(/usr/local/QVision/qvproject.pri)
TARGET = example
SOURCES = example.cpp
</pre></div><p>The project file of any QVision application must include the file <em>qvproject.pri</em>. This file can be found at the QVision library path. It contains the setup for the qmake tool to compile applications with the QVision.</p>
<p>The line <em>TARGET = example</em> in our <em>.pro</em> example file sets the name of the application's executable to <em>example</em>. <em>TARGET</em> is a reserved variable name that should contain the name of the executable objective of the compilation. The variable <em>SOURCES</em> must contain a space separated list of the source files of the application. In our example, the project has only one source file named <em>example.cpp</em>.</p>
<p>We can store the previous project file with the name <em>example.pro</em> along with the source file <em>example.cpp</em> described below, which will contain the source code of our <em>hello-world</em> application.</p>
<h2><a class="anchor" id="QVisionHelloWorldSourceCode">
Source code for the 'example.cpp' file</a></h2>
<p>We can insert the following code in the <em>example.cpp</em> file:</p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#include &lt;iostream&gt;</span>
<span class="preprocessor">#include &lt;qvimageio.h&gt;</span>

<span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])
        {
        <span class="comment">// Check if the user provided enough command line parameters.</span>
        <span class="keywordflow">if</span> (argc &lt; 3)
                {
                std::cout &lt;&lt; <span class="stringliteral">&quot;Usage: &quot;</span> &lt;&lt; argv[0] &lt;&lt; <span class="stringliteral">&quot; &lt;input image&gt; &lt;output image&gt;&quot;</span> &lt;&lt; std::endl;
                <span class="keywordflow">return</span> -1;
                }

        <span class="comment">// Input and output images</span>
        <a class="code" href="classQVImage.html">QVImage&lt;uChar, 3&gt;</a> image;

        <span class="comment">// Read the input image</span>
        <a class="code" href="group__qvip.html#ga59a032b0b1c38254a95e383a39bf33a0" title="Reads the content of a QVImage (RGB) object from an image file.">readQVImageFromFile</a>(argv[1], image);

        <span class="comment">// Write output image</span>
        <a class="code" href="group__qvip.html#ga77ad534a38a3c6e3de5607c07cc0e999" title="Write the content of a QVImage (RGB) object in an image file.">writeQVImageToFile</a>(argv[2], image);
        
        <span class="keywordflow">return</span> 0;
        }
</pre></div><p>This simple example loads an image from a file named <em>image.png</em>, and stores that same image in another file named <em>image-copy.png</em>.</p>
<h3><a class="anchor" id="ExecuteCompile">
Compiling and executing the program</a></h3>
<p>Once the files <em>example.cpp</em> and <em>example.pro</em> are created in the same directory, you can compile and run the application.</p>
<p>You can use the <em>qmake-qt4</em> and the <em>make</em> tools to do so from the Linux command shell:</p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">        # qmake-qt4</span>
<span class="preprocessor">        # make</span>
</pre></div><p>This should create the binary executable <em>example</em>. You can execute the application using a command line like the following:</p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">        # ./example</span>
</pre></div><p>If you are using the <em>Qt Creator</em>, simply load the file <em>example.pro</em>. This creates a new project containing the source for the small code example described above. You can then compile and execute the example application. </p>
</div>
</td></tr></table>

<br /><hr><br />
<center><a href="http://perception.inf.um.es/QVision">QVision framework</a>.
<a href="http://perception.inf.um.es">PARP research group</a>.
Copyright &copy; 2007, 2008, 2009, 2010, 2011.</center>
<br />
</body>
</html>
